﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using COFE.Core.Lister;
using NUnit.Framework;
using COFE.Core;
using COFE.Core.Profile;

namespace COFE.Core.UnitTest
{
    public abstract class TestSecondaryDirectoryLister<T,ST> : TestDirectoryLister<T>
        where ST : ISecondaryDirectoryLister
        where T : IDirectoryLister         
    {
         #region Constructor

        public TestSecondaryDirectoryLister(T directoryLister, string rootTestPath,
            ST secondaryDirectoryLister, string virtualDirName, string virtualDirType)
            : base(directoryLister, rootTestPath)
        {
            Assert.IsNotNullOrEmpty(secondaryDirectoryLister.ListerKey);
            _userProfile.RegisterVolume(directoryLister);
            _userProfile.RegisterVolume(secondaryDirectoryLister);          
            Assert.IsFalse(virtualDirName.StartsWith("."));


            //Delete Virtual File first
            _rootTestPath = COFEPath.Combine(_rootTest.ParseName, virtualDirName + "." + virtualDirType);
            _userProfile.File.Delete(_rootTestPath);
            //Then create it.
            _rootTest = _rootTest.CreateVirtualDirectory(virtualDirName, virtualDirType) as IInternalDirectoryInfoExA;
            Assert.IsNotNull(_rootTest);
            Assert.AreEqual(_rootTest.ParseName, _rootTestPath);            
        }

        #endregion

        #region Methods

        [Test]
        public override void Test()
        {
            CleanUp();
            CreateDirectories();
            CreateFiles();
            CopyFiles();
            PollFileProperties();
            PollDirectoryProperties();
            RemoveFiles();
            RemoveDirectories();
        }


        #endregion

    }
}
